<?php
namespace Core;

class TanbaSwooleTable
{
    public $client;
    public $tanbalist;
    public $STAclient;
    public $RFclient;

    public function __construct()
    {
        try {

            //创建客户端连接内存表 key是fd
            $this->client = new  \Swoole\table(65535);
            $this->client->column('fd', \Swoole\table::TYPE_INT, 8);
            $this->client->column('deviceID', \Swoole\table::TYPE_STRING, 64);
            $this->client->column('tbid', \Swoole\table::TYPE_INT, 8);
            $this->client->column('id', \Swoole\table::TYPE_INT, 8);
            $this->client->column('status', \Swoole\table::TYPE_INT, 2);//当前状态
            $this->client->column('token', \Swoole\table::TYPE_INT, 8);
            $this->client->column('newtoken', \Swoole\table::TYPE_INT, 8);
            $this->client->column('devicetype', \Swoole\table::TYPE_STRING, 64);//设备类型
            $this->client->column('version', \Swoole\table::TYPE_STRING, 16);//协议版本

            $this->client->column('encodetype', \Swoole\table::TYPE_STRING, 16); //加密算法
            $this->client->column('checktype', \Swoole\table::TYPE_STRING, 16);//校验算法
            $this->client->column('ability', \Swoole\table::TYPE_STRING, 16);//设备能力

            $this->client->column('openheart', \Swoole\table::TYPE_INT, 1);//是否已开启心跳

            $this->client->column('ismove', \Swoole\table::TYPE_INT, 2);//是否移动探霸1是
            $this->client->column('baseinfo', \Swoole\table::TYPE_STRING, 200);//设备信息
            $this->client->column('location', \Swoole\table::TYPE_STRING, 100);//位置
            $this->client->column('lasttime', \Swoole\table::TYPE_STRING, 11);

            $this->client->column('firsttime', \Swoole\table::TYPE_STRING, 16);

            $this->client->column('tcount', \Swoole\table::TYPE_INT, 8);//总包
            $this->client->column('a000tc', \Swoole\table::TYPE_INT, 8);//
            $this->client->column('a000dc', \Swoole\table::TYPE_INT, 8);//AP总数
            $this->client->column('a001tc', \Swoole\table::TYPE_INT, 8);
            $this->client->column('a001dc', \Swoole\table::TYPE_INT, 8);
            $this->client->column('a002tc', \Swoole\table::TYPE_INT, 8);
            $this->client->column('a002dc', \Swoole\table::TYPE_INT, 8);

            $this->client->column('Errotc', \Swoole\table::TYPE_INT, 8);//错误类型数据

            $this->client->column('receivects', \Swoole\table::TYPE_INT, 16);
            $this->client->column('othercts', \Swoole\table::TYPE_INT, 16);
            $this->client->column('invalid', \Swoole\table::TYPE_INT, 8); //无效或校验异常

            $this->client->column('stcount', \Swoole\table::TYPE_INT, 8);//发送总包数
            $this->client->column('sentcts', \Swoole\table::TYPE_INT, 16);

            $this->client->column('hrtsd', \Swoole\table::TYPE_INT, 8);//发送心跳次数
            $this->client->column('hrtrsv', \Swoole\table::TYPE_INT, 8);//接收心跳次数
            $this->client->column('hrtstatus', \Swoole\table::TYPE_INT, 2);
            $this->client->column('openheart', \Swoole\table::TYPE_INT, 2);
            $this->client->column('hrtsderr', \Swoole\table::TYPE_INT, 8);//发送心跳次数

            $this->client->column('openheart', \Swoole\table::TYPE_INT, 2);
            $this->client->column('hrtsderr', \Swoole\table::TYPE_INT, 8);//发送心跳次数


            $this->client->column('lock', \Swoole\table::TYPE_INT, 2);

            $this->client->create();

            //客户端连接内存表 client--反向表// key是tbmac -
            $this->tanbalist = new  \Swoole\table(32768);
            $this->tanbalist->column('fd', \Swoole\table::TYPE_INT, 8);
            $this->tanbalist->column('tbid', \Swoole\table::TYPE_INT, 8);
            $this->tanbalist->column('lastouttime', \Swoole\table::TYPE_STRING, 11);
            $this->tanbalist->column('lastintime', \Swoole\table::TYPE_STRING, 11);
            $this->tanbalist->column('lasttime', \Swoole\table::TYPE_STRING, 11);
            $this->tanbalist->create();

            //客户端心跳内存池
            $this->heartlist = new  \Swoole\table(32768);
            $this->heartlist->column('fd', \Swoole\table::TYPE_INT, 8);
            $this->heartlist->column('tbmac', \Swoole\table::TYPE_STRING, 64);

            $this->heartlist->column('token', \Swoole\table::TYPE_STRING, 12);
            $this->heartlist->column('intime', \Swoole\table::TYPE_STRING, 11);
            $this->heartlist->column('timer', \Swoole\table::TYPE_INT, 4); //分钟
            $this->heartlist->column('sendtime', \Swoole\table::TYPE_STRING, 11);//最后一次发送时间
            $this->heartlist->column('senderro', \Swoole\table::TYPE_INT, 4);
            $this->heartlist->column('resvtime', \Swoole\table::TYPE_STRING, 11);//最后一次发送时间
            $this->heartlist->column('status', \Swoole\table::TYPE_INT, 1);//发送状态
            $this->heartlist->column('hrtstatus', \Swoole\table::TYPE_INT, 1);//回执状态
            $this->heartlist->create();


            //监听端口链接表 // key是链接id
            $this->listener = new  \Swoole\table(1024);
            $this->listener->column('fd', \Swoole\table::TYPE_INT, 8);
            $this->listener->column('lasttime', \Swoole\table::TYPE_STRING, 11);
            $this->listener->column('remote_ip', \Swoole\table::TYPE_STRING, 64);
            $this->listener->column('remote_port', \Swoole\table::TYPE_STRING, 10);
            $this->listener->column('cmddata', \Swoole\table::TYPE_STRING, 200); //命令参数
            $this->listener->create();

            //系统参数配置--可随时修改的-同步数据库监控
            $this->sysconfig = new  \Swoole\table(1024);
            $this->sysconfig->column('value', \Swoole\table::TYPE_STRING, 100);
            $this->sysconfig->create();

            //oui内存对照库- key是Assignment  value --uid
            $this->ouibase = new  \Swoole\table(65535);
            $this->ouibase->column('uid', \Swoole\table::TYPE_INT, 8);
            $this->ouibase->column('ouiname', \Swoole\table::TYPE_STRING, 200);
            $this->ouibase->create();

            
        } catch (Exception $e) {
            echo $e->getMesasge();
        }

    }



}